package 代码记录.校招笔试真题.笔试真题_2022.海能达;


import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * 5 ^ 2 == 7   101 ^ 10 == 111
 * 输入：3+5^2-9
 * 11 +
 * 输出：1
 * System.out.println(3 + (5 | 2) - 9);
 * 奇怪的计算器
 */
public class Test2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        char[] line = sc.nextLine().toCharArray();
        for(int i = 0;i < line.length;i++){
            if(line[i] == '^'){
                line[i] = '|';
            }
        }
        for(int i = 1;i < line.length - 1;i++){
            if(line[i] == '|'){
                int a = line[i - 1] - '0';
                int b = line[i + 1] - '0';
                int c = a | b;
                line[i - 1] = 'a';
                line[i + 1] = 'a';
                line[i] = (char)(c + '0');
            }
        }
        List<Character> list = new ArrayList<>();
        for(int i = 0;i < line.length;i++){
            if((line[i] >= '0' && line[i] <= '9') || line[i] == '+' || line[i] == '-'){
                list.add(line[i]);
            }
        }
        long res = 0;//3 + 7 - 9
        res += (list.get(0) - '0');
        for(int i = 1;i < list.size();i++){
            if(list.get(i) == '+'){
                res += (list.get(i + 1) - '0');
            }
            if(list.get(i) == '-'){
                res -= (list.get(i + 1) - '0');
            }
        }
        System.out.println(res);
    }
}
